﻿<UserControl x:Class="SlotDuino.UI.Controls.FreeRacesControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dal="clr-namespace:SlotDuino.DAL;assembly=SlotDuino.DAL"
             xmlns:converter="clr-namespace:SlotDuino.Converter"
             mc:Ignorable="d" 
             Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <CollectionViewSource x:Key="racesSource" d:DesignSource="{d:DesignInstance dal:FreeRace, CreateList=True}" />
        <converter:NotNull x:Key="NotNull" />
    </UserControl.Resources>

    <StackPanel x:Name="layoutRoot" Width="165">
        <Button Content="Nova Corrida" Height="50" Margin="0,0,0,10" Click="btnNewRace_Click" Name="btnNewRace" TabIndex="1" />
        <DataGrid DataContext="{Binding Source={StaticResource racesSource}}" Background="{StaticResource SelectedBackgroundBrush}" Height="200" Name="dtgOngoingRaces" Visibility="{Binding ElementName=btnNewRace, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" ItemsSource="{Binding}" AutoGenerateColumns="False" CanUserAddRows="False" Margin="0,0,0,10">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding State}" IsReadOnly="True" />
                <DataGridTextColumn Header="Corrida" Binding="{Binding Id}" IsReadOnly="True" />
                <!--
                <DataGridTextColumn Header="Tempo" IsReadOnly="True" />
                -->
            </DataGrid.Columns>
        </DataGrid>

        <Button Content="Iniciar Corrida" Height="50" Margin="0,0,0,10" Name="btnStartRace" IsEnabled="{Binding Source={StaticResource racesSource}, Path=/, Converter={StaticResource NotNull}}" TabIndex="2" Click="btnStartRace_Click" Visibility="{Binding ElementName=btnNewRace, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" />
        <Button Content="Fechar Corrida" Height="50" Margin="0,0,0,10" Name="btnCloseRace" IsEnabled="{Binding Source={StaticResource racesSource}, Path=/, Converter={StaticResource NotNull}}" TabIndex="3" Click="btnCloseRace_Click" Visibility="{Binding ElementName=btnNewRace, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" />
        <Button Content="Interromper Corridas" Height="50" Margin="0,0,0,10" Name="btnPauseRaces" TabIndex="4" Click="btnPauseRaces_Click" Visibility="{Binding ElementName=btnNewRace, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" />
        <Button Content="Retomar Corridas" Height="50" Margin="0,0,0,10" Name="btnResumeRaces" TabIndex="5" Click="btnResumeRaces_Click" Visibility="{Binding ElementName=btnNewRace, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" />
    </StackPanel>
</UserControl>
